package com.jiutong.meipenggang.http.present;

import android.content.Context;

import com.jiutong.meipenggang.entity.ServiceAgreementBean;
import com.jiutong.meipenggang.http.model.interfaces.BaseBiz;
import com.jiutong.meipenggang.http.model.requests.UserInfoRequest;
import com.jiutong.meipenggang.http.subscribers.ProgressSubscriber;
import com.jiutong.meipenggang.http.subscribers.SubscriberOnNextListener;
import com.jiutong.meipenggang.utils.TimeUitl;

import java.util.HashMap;

/**
 * @author Veken
 * @date on 2017/12/22 14:56
 * @describe
 */

public class ServiceAgreementPresent {
    private Context mContext;
    private UserInfoRequest userInfoRequest;
    private BaseBiz baseBiz;

    public ServiceAgreementPresent(Context mContext, BaseBiz baseBiz) {
        this.mContext = mContext;
        this.baseBiz = baseBiz;
        userInfoRequest = new UserInfoRequest();
    }

    /**
     * 服务协议
     */
    public void serviceAgreement() {
        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<ServiceAgreementBean>() {
            @Override
            public void onNext(ServiceAgreementBean subjects) {
                baseBiz.onSuccess(subjects);
            }

            @Override
            public void onError(Throwable e) {
                baseBiz.onError(e);
            }
        };

        HashMap<String, Object> fieldsMap = new HashMap<>();
        fieldsMap.put("OPT", baseBiz.getOpt());
        fieldsMap.put("timestamp", TimeUitl.getDate());
        userInfoRequest.serviceAgreement(new ProgressSubscriber(onNextListener, mContext), fieldsMap);
    }
}
